/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ni;

import Presenter.Presenter;
import java.io.File;
import java.net.SocketException;
import java.net.UnknownHostException;
import model.RemoteUser;

/**
 *
 * @author yorrickbarnay
 */
public class NIFacade implements FromPresenter {
    
    private NI ni;
    
    public NIFacade(Presenter p) throws SocketException, InterruptedException, UnknownHostException
    {
        ni = new NI(p);
    }
    @Override
    public void performHello(){
        ni.sendHello(ni.getLocalName());
    }
    
    @Override
    public void performHelloAck(RemoteUser r){
        ni.sendHelloAck(ni.getLocalName(), r.getAddr());
    }
    
    @Override
    public void performSend(String text2send,RemoteUser r){
        ni.sendSend(text2send,0, r.getAddr());
    }
    
    //prendre le dernier user de la liste
    @Override
    public void performGoodbye(){
        ni.sendGoodbye(ni.getLocalName());
    }
    
    @Override
    public void performFileRequest(String file_name, RemoteUser r){
        ni.sendFileRequest(file_name, r.getAddr());
    }
    
    @Override
    public void performFileResponse(boolean accord, String file_name, RemoteUser r){
        ni.sendFileResponse(accord, file_name, r.getAddr());
    }
    
    @Override
    public void performFileSend(File file, RemoteUser r){
        if(file != null)
            ni.sendFile(file, r.getAddr());
    }
    /*
    public void launchNI(){
        ni.startServer();
    }*/
    
    @Override
    public void blockNI(){
        ni.setActiv(false);
    }
    @Override
    public void unblockNI(){
        ni.setActiv(true);
    }
}
